using System;

namespace BardsTaleMapViewer {
  public static class Dice {
    //int _a;
    //int _b;
    //int _n;

    // = BdA - n lowest of dA
    // Dice (15, 2, 1) = 2d15 - 1x lowest of d15 ~= 1d15
    // Dice (60, 2, 1) = 2d60 - 1x lowest of d60 ~= 1d60
    //public Dice (int a, int b, int n) {
    //  _a = a;
    //  _b = b;
    //  _n = n;
    //}

    public static string DiceString (int a, int b, int n, int al, int bl) {
      if (n == 0)
        return (string.Format ("{0," + bl + "}d{1," + al + "}", b, a));
      else
        //return (string.Format ("{0}d{1} - n lowest of d{1}", _b, _a));
        throw new Exception ();
    }

    public static string DiceWithMinMaxString (int a, int b, int n, int al, int bl, int minl, int maxl) {
      return (DiceWithMinMaxString (a, b, n, 0, al, bl, minl, maxl, 1));
      //if (n == 0) {
      //  string diceString = DiceString (a, b, n, al, bl);
      //  string minMaxString = MinMaxString (a, b, n, minl, maxl);
      //  return (string.Format ("{0}={1}", diceString, minMaxString));
      //}
      //else
      //  throw new Exception ();
    }

    public static string DiceWithMinMaxString (int a, int b, int n, int bonus, int al, int bl, int minl, int maxl, int bonusl) {
      if (n == 0) {
        string diceString = DiceString (a, b, n, al, bl);
        string minMaxString = MinMaxString (a, b, n, bonus, minl, maxl);
        return (string.Format ("{0}{1," + bonusl + "}={2}", diceString, (bonus == 0) ? "" : "+" + bonus, minMaxString));
      }
      else
        throw new Exception ();
    }

    public static int Min (int a, int b, int n) {
      return (Min (a, b, n, 0));
      //if (n == 0)
      //  return (b * 1);
      //else
      //  throw new Exception ();
    }

    public static int Min (int a, int b, int n, int bonus) {
      if (n == 0)
        return (b * 1 + bonus);
      else
        throw new Exception ();
    }

    public static int Max (int a, int b, int n) {
      return (Max (a, b, n, 0));
      //if (n == 0)
      //  return (b * a);
      //else
      //  throw new Exception ();
    }

    public static int Max (int a, int b, int n, int bonus) {
      if (n == 0)
        return (b * a + bonus);
      else
        throw new Exception ();
    }

    public static string MinMaxString (int a, int b, int n, int minl, int maxl) {
      return (MinMaxString (a, b, n, 0, minl, maxl));
      //if (n == 0) {
      //  return (string.Format ("[{0," + minl + "};{1," + maxl + "}]", Min (a, b, n), Max (a, b, n)));
      //}
      //else
      //  throw new Exception ();
    }

    public static string MinMaxString (int a, int b, int n, int bonus, int minl, int maxl) {
      if (n == 0) {
        return (string.Format ("[{0," + minl + "};{1," + maxl + "}]", Min (a, b, n, bonus), Max (a, b, n, bonus)));
      }
      else
        throw new Exception ();
    }
  }
}
